package com.kmproject.haifu.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.HouseInfoTitleBean;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;
import com.kmproject.haifu.mvp.ui.activity.HouseRentingShowDuanZuListActivity;

import java.util.List;

public class PopuWindowSelectSxItemAdapter extends BaseQuickAdapter<HousePayWayBean, BaseViewHolder> {
    public PopuWindowSelectSxItemAdapter( @Nullable List<HousePayWayBean> data) {
        super(R.layout.selectroom_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HousePayWayBean item) {

        if (helper.getPosition() == 0){
                item.setSelect(true);
        } else {
            item.setSelect(false);
        }

     if (item.getName().contains("（"))
     {
         helper .<TextView> getView(R.id.housepublic_item_item_tv).setText(item.getName().substring(0,item.getName().indexOf("（")));
     }else {
         helper .<TextView> getView(R.id.housepublic_item_item_tv).setText(item.getName());
     }

    helper .<TextView> getView(R.id.housepublic_item_item_tv).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick (View v){
            item.setSelect(!item.isSelect());
            if (helper.getPosition()==0&&item.isSelect())
            {
                HouseRentingShowDuanZuListActivity.isOpen=true;
            }else {
                HouseRentingShowDuanZuListActivity.isOpen=false;
            }
            notifyDataSetChanged();
        }
    });

          if(item.isSelect())
    {
        helper.<TextView>getView(R.id.housepublic_item_item_tv).setTextColor(ArmsUtils.getColor(mContext, R.color.color_191919));
        helper.<TextView>getView(R.id.housepublic_item_item_tv).setBackgroundResource(R.drawable.square_yellow_bg);
    }else

    {
        helper.<TextView>getView(R.id.housepublic_item_item_tv).setTextColor(ArmsUtils.getColor(mContext, R.color.white));
        helper.<TextView>getView(R.id.housepublic_item_item_tv).setBackgroundResource(R.drawable.square_gray_bg);
    }
}
}
